@extends('admin.layouts.app')
@section('content')
    <div class="page-header">
        <h3 class="page-title">
        编辑产品分类
        </h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="#">产品分类管理</a></li>
                <li class="breadcrumb-item active" aria-current="page">编辑分类</li>
            </ol>
        </nav>
    </div>
    <div class="row">
        <div class="col-md-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">


            {!! Form::open(['route' => ['admin.cate.update',$res->id], 'method' => 'PATCH']) !!}
                        @csrf
                        <div class="form-group">
                            <label for="pid">上级分类</label>
                            <select class="form-control" name="pid" id="pid">
                            <option value="0">顶级分类</option>
                            @foreach($cates as $cate)
                                <option {{($cate->id == $res->pid)?"selected":""}} value="{{$cate->id}}">{{($cate->level==0)?"":"|"}}{{str_repeat("------",$cate->level)}}{{$cate->name}}</option>
                            @endforeach
                            </select>
                        </div>
                        <input type="hidden" name="id" value="{{$res->id}}">
                        {!! $errors->update->first('pid','<div class="alert alert-danger col-md-12 grid-margin stretch-card">:message</div>') !!}
                        <div class="form-group">
                            <label for="name">分类名称</label>
                            <input type="text" value="{{$res->name}}" name="name" class="form-control" id="name" placeholder="请输入分类名称">
                        </div>
                        <div class="form-group">
                            <label for="sort">排序</label>
                            <input type="text" name="sort" value="{{$res->sort}}" class="form-control" id="sort" placeholder="请输入排序">
                        </div>
                        <button type="submit" class="btn btn-gradient-primary mr-2">保存</button>
                        {!! Form::close() !!}
                </div>
            </div>
        </div>
    </div>
@endsection
